<template>
    <div>
        <div class="tab-back"><span class="left" @click="toback()"></span><div class="title">修改价格</div><div class="right"></div></div>
        <div class="box-r4" style="padding-bottom: 15px;">
            <div class="tips_title">修改售价<p class="red_ft">当前售价： ￥{{price}}
                <!--<img style="width: 12px;height: 12px" src="../../assets/img/money_icon.png"/>-->
            </p></div>
            <input type="number" class="input_text" placeholder="填写金额/元，0则为免费" v-model="newprice" @keyup="pricechange()">
        </div>
        <input type="button" class="red_btn btn-bottom" value="确认修改" @click="changesub()">
    </div>
</template>

<script>
    export default {
        name: "",
        data(){
            return {
                materialsid:"",
                price:"",
                newprice:""
            }
        },
        mounted(){
            this.materialsid=this.$route.params.id;
            this.price=this.$route.params.price;
        },
        methods:{
            pricechange(){
                this.newprice=parseFloat(this.newprice)
            },
            toback(){
                this.$router.go(-1);//返回上一层
            },
            changesub(){
                var that=this;
                that.request1.post1({
                    url: that.Url + "api/materials/myDetailSave",
                    params: {   materialsid:that.materialsid, price:that.newprice},
                    success: function (res) {
                        console.log(res)
                        if (res.data.code == 1) {
                            that.$toast.success("修改成功");
                            that.$router.go(-1);
                        } else {
                            alert(res.data.msg)
                        }
                    },
                    fail: function (error) {
                        alert(error.data.msg)
                    }
                })
            }
        },
    }
</script>

<style scoped>
    .tab-back {
        height: 44px;
        background: #fc5d4d;
        display: -webkit-box;
    }
    .tab-back .left {
        width: 44px;
        display: block;
        height: 44px;
        background: url() no-repeat 50%;
        background-size: 9px 16px;
    }
    .tab-back .title {
        -webkit-box-flex: 1;
        font-size: 15px;
        color: #fff;
        font-weight: 700;
        text-align: center;
        line-height: 44px;
    }
    .tab-back .right {
        width: 44px;
        height: 44px;
    }
    .box-r4, .red_btn {
        border-radius: 4px;
    }
    .box-r4 {
        display: block;
        background: #fff;
        margin: 7px 10px 0;
        padding: 0 15px;
        overflow: hidden;
    }
    .tips_title {
        font-size: 14px;
        font-weight: 700;
        color: #000;
        display: block;
        line-height: 14px;
        padding-top: 20px;
        padding-bottom: 10px;
    }
    .tips_title p {
        font-size: 12px;
        display: inline-block;
        padding-left: 10px;
    }
    .red_ft {
        color: #fc5d4d !important;
    }
    .input_text {
        height: 36px;
        border-radius: 4px;
        font-size: 13px;
        border: 1px solid #e5e5e5;
        padding: 0 4%;
        background: #f9f9fb;
        width: 92%;
        display: block;
        margin-bottom: 15px;
    }
    .red_btn {
        background: #fc5d4d;
        color: #fff;
        font-size: 14px;
        text-align: center;
        height: 40px;
        line-height: 40px;
        width: 90%;
        margin: 20px 5% 100px;
        box-shadow: 0 5px 10px #f6a59f;
    }
    .box-r4, .red_btn {
        border-radius: 4px;
    }
    .btn-bottom {
        position: fixed;
        bottom: 20px;
        margin-bottom: 0 !important;
    }
</style>